<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
if($_RQ['op']=='main'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		$this->plugin_setting('basic',$postdata);
		exi('设置成功');
	}
	$formfileds =array(
		array('title'=>'别名','type'=>1,'isopen'=>1,'value'=>'可点击命名：如家长姓名、学生名字、楼层等'),
		array('title'=>'编号','type'=>1,'isopen'=>1,'value'=>'可点击命名：如家长学号、工号、座号等'),
		array('title'=>'联系人','type'=>'1','isopen'=>1,'ismust'=>'0','value'=>''),
		array('title'=>'联系电话','type'=>'8','isopen'=>1,'ismust'=>'0','value'=>''),
		array('title'=>'联系地址','type'=>'7','ismust'=>'0','value'=>''),
	);
	$hudongfileds =array(
		array('title'=>'你的想法','type'=>'1','ismust'=>'0','value'=>'您的想法'),
	);
	$baomingfileds =array(
		array('title'=>'项目名称','type'=>'1','nodel'=>1,'ismust'=>'0','value'=>'项目名称'),
		array('title'=>'费用(￥)','type'=>'18','nodel'=>1,'ismust'=>'0','value'=>''),
		array('title'=>'人数','type'=>'2','nodel'=>1,'ismust'=>'0','value'=>'10'),
	);
	$pingxuanfileds =array(
		array('title'=>'选项','type'=>'1','ismust'=>'0','value'=>'','image'=>''),
		array('title'=>'选项','type'=>'1','ismust'=>'0','value'=>'','image'=>''),
	);
	$groupfileds =array(
		array('title'=>'商品名称','type'=>'1','nodel'=>1,'ismust'=>'0','value'=>'商品名称'),
		array('title'=>'商品图片','type'=>'3','nodel'=>1,'ismust'=>'0','value'=>'商品图片'),
		array('title'=>'单位(件)','type'=>'1','nodel'=>1,'ismust'=>'0','value'=>''),
		array('title'=>'价格(￥)','type'=>'18','nodel'=>1,'ismust'=>'0','value'=>''),
		array('title'=>'库存','type'=>'2','nodel'=>1,'ismust'=>'0','value'=>'1000'),
	);
	$bgimgs =array(
		array('picurl'=>'../addons/jy_quan/resource/images/bgimg01.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/bgimg02.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/bgimg03.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/bgimg04.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/bgimg05.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/bgimg06.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/bgimg07.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/bgimg08.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/bgimg09.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/bgimg10.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/bgimg11.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/bgimg12.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/bgimg13.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/bgimg14.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/bgimg15.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/bgimg16.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/bgimg17.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/bgimg18.jpg'),
	);
	$readtpls =array(
		array('picurl'=>'../addons/jy_quan/resource/images/readtpl01.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/readtpl02.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/readtpl03.jpg'),
		array('picurl'=>'../addons/jy_quan/resource/images/readtpl04.jpg'),
	);
	$footernav =array(
		array('title'=>'首页','icon'=>'icon-shouye','action'=>'jy_quan/index/'),
		array('title'=>'我的圈','icon'=>'icon-yonghujieru','action'=>'jy_quan/myquan/'),
		array('title'=>'发现商户','icon'=>'icon-map','action'=>'jy_quan/merch/'),
		array('title'=>'我的小店','icon'=>'icon-dianpu','action'=>'jy_merch/myshop/'),
		array('title'=>'会员中心','icon'=>'icon-wo1','action'=>'jy_quan/myhome/'),
	);
	$plugins =$this->plugins();
	$return['item']=$this->plugin_setting('basic');
	$return['item']['pcd_type']=$return['item']['pcd_type']?:'0';
	$return['item']['formfileds']=$return['item']['formfileds']?$return['item']['formfileds']:$formfileds;
	$return['item']['baomingfileds']=$return['item']['baomingfileds']?$return['item']['baomingfileds']:$baomingfileds;
	$return['item']['pingxuanfileds']=$return['item']['pingxuanfileds']?$return['item']['pingxuanfileds']:$pingxuanfileds;
	$return['item']['groupfileds']=$return['item']['groupfileds']?$return['item']['groupfileds']:$groupfileds;
	$return['item']['hudongfileds']=$return['item']['hudongfileds']?$return['item']['hudongfileds']:$hudongfileds;
	$return['item']['bgimgs']=$return['item']['bgimgs']?$return['item']['bgimgs']:$bgimgs;
	$return['item']['readtpls']=$return['item']['readtpls']?$return['item']['readtpls']:$readtpls;
	$return['item']['plugins']=$return['item']['plugins']?$return['item']['plugins']:$plugins[1]['list'];
	$return['item']['footernav']=$return['item']['footernav']?$return['item']['footernav']:$footernav;
	$return['item']['open_types']=$return['item']['open_types']?:';0;1;2;3;4;5;6;7;8;';
	$return['open_types']=$this->itemtypes();
	$htmls=array(
		'type'=>'edit',
		'desc'=>'参数设置',
		'tabs'=>$tabs,
		'edit_tab'=>true,
		'edits'=>array(
			array(
				'title'=>'基本信息',
				'list'=>array(
					array('type'=>'string','title'=>'网站名称','name'=>'title'),
					array('type'=>'image','title'=>'网站logo','name'=>'logo'),
					array('type'=>'image','title'=>'顶部背景图','name'=>'topbg','help'=>'建议尺寸宽480，高300'),
					array('type'=>'switch','title'=>'开启地方圈?','name'=>'issns','help'=>'开启地方圈后，将根据不同行政区域展示圈主题信息！形成一个村圈！<red>同时圈主的权限才生效！</red>'),
					array('type'=>'radio','title'=>'圈级设置?','name'=>'pcd_type','options'=>'pcd_types','help'=>'开启地方圈后有效；例如：区/县级圈，表示：自动以区/县作为一个圈！'),
					array('type'=>'switch','title'=>'开启小程序审核模式?','name'=>'open_wxappsh','help'=>'开启小程序审核模式后，所有发帖信息，留言都不显示！包括我的圈里面；会员中心/充值/及收到红包，不显示！'),
					array('type'=>'switch','title'=>'开启留言审核?','name'=>'msg_shenhe'),
					array('type'=>'switch','title'=>'开启帖子审核?','name'=>'item_shenhe'),
					array('type'=>'switch','title'=>'关闭拼团阶梯?','name'=>'no_pingtuan'),
					array('type'=>'switch','title'=>'拼团/互动支持多次接龙?','name'=>'is_jiemore','help'=>'开启拼团/互动类型支持多次接龙'),

					array('type'=>'switch','title'=>'不显示已结束帖子?','name'=>'no_showpassitem','help'=>'关闭后，首页不显示已经结束的接龙！'),
					array('type'=>'checkbox','title'=>'开启主题类型?','name'=>'open_types','options'=>'open_types'),
					array('type'=>'switch','title'=>'开启余额红包?','name'=>'isideal_money','help'=>'开启余额红包后，就关闭了微信红包，改用账户余额红包，红包资金进入奖金池，奖金池可以提现或转到余额'),
					array('type'=>'text','title'=>'地方圈默认描述','name'=>'quan_desc','help'=>'生活圈，分享时时动态，了解周边接龙活动信息！这里有拼团、预约、报名、二手信息、拼车、互动...'),
					array('type'=>'string','title'=>'地方圈默认地址','name'=>'quan_district','help'=>'例如：小周圈村庄'),
					array('type'=>'text','title'=>'主圈描述','name'=>'zhu_desc','help'=>'区别于地方圈，可以用于圈业务描述，新手引导，售后服务等'),
					array('type'=>'string','title'=>'分享标题','name'=>'share_title'),
					array('type'=>'image','title'=>'分享图片','name'=>'share_image'),
					array('type'=>'text','title'=>'分享描述','name'=>'share_desc'),
				)
			),
			array(
				'title'=>'管理员/圈主设置',
				'list'=>array(
					array('type'=>'choose','title'=>'管理员UID','name'=>'adminuid','action'=>'core/member.get_member/','choose_title'=>'选择会员','help'=>'便于接收平台高级消息！'),
					array('type'=>'choose','title'=>'客服人员ID','name'=>'kefuid','action'=>'core/member.get_member/','choose_title'=>'选择会员'),
					array('type'=>'choose_many','name'=>'sysmid','title'=>'审核维护员ID','action'=>'core/member.get_member/many/','choose_title'=>'选择会员'),
                    array('type'=>'switch','title'=>'开启圈主固定？','name'=>'boss_nochange','help'=>'启用后，不会根据自己的IP流量被别人超过而被替换圈主！'),
                    array('type'=>'string','title'=>'圈主每天/每圈最高发帖数','name'=>'boss_itemnum','help'=>'留空则不限制！'),
                    array('name'=>'bossfee','title'=>'圈主收益','type'=>'string','help'=>'不填表示不支持；填写数字表示固定佣金，填写%，表示按百分比计算佣金'),
                    array('type'=>'checkbox','title'=>'支持的提现方式','name'=>'withdrawtype','options'=>'withdraw'),
                    array('type'=>'string','title'=>'圈主收益结算额度（元）','name'=>'balance_money','help'=>'佣金达到该数值才能结算'),
                    array('type'=>'unitstring','unit'=>'%','title'=>'圈主收益打款手续费（%）','name'=>'balance_per'),
				)
			),
			array(
				'title'=>'接龙设置',
				'list'=>array(
					array('type'=>'tip','title'=>'<red>[温馨提示]：每种表单必须至少存在一项内容！！考虑统一性，报名表单信息，商品表单信息不允许编辑！</red>'),
					array(
							'type'=>'array',
							'name'=>'formfileds',
							'title'=>'参与人填写表单',
							'add_tip'=>'参与人填写表单',
								'list'=>array(
									array('type'=>'string','name'=>'title','title'=>'标题'),
									array('type'=>'radio','name'=>'type','title'=>'类型','options'=>'types'),
									array('type'=>'radio','name'=>'ismust','title'=>'*必填?','options'=>'ismust'),
								),
								'details'=>array(
									array('type'=>'string','name'=>'title','title'=>'标题','help'=>''),
									array('type'=>'radio','name'=>'type','title'=>'类型','options'=>'types'),
									array('type'=>'switch','name'=>'ismust','title'=>'*必填?'),
								)
					),
					array(
							'type'=>'array',
							'name'=>'hudongfileds',
							'title'=>'互动类填写表单',
							'add_tip'=>'互动类填写表单（互动类的帖子才有效）',
								'list'=>array(
									array('type'=>'string','name'=>'title','title'=>'标题'),
									array('type'=>'radio','name'=>'type','title'=>'类型','options'=>'types'),
									array('type'=>'radio','name'=>'ismust','title'=>'*必填?','options'=>'ismust'),
									
								),
								'details'=>array(
									array('type'=>'string','name'=>'title','title'=>'标题','help'=>''),
									array('type'=>'radio','name'=>'type','title'=>'类型','options'=>'types'),
									array('type'=>'switch','name'=>'ismust','title'=>'*必填?'),
								)
						),
				)
			),
			array(
				'title'=>'全局帖子',
				'list'=>array(
					array('type'=>'switch','name'=>'issys_item','title'=>'开启全局显示下面帖子?','help'=>'开启后，全局顶部会显示下面的帖子'),
					array('type'=>'choose_many','name'=>'sysitems','title'=>'选择帖子','option_title'=>'title','action'=>'jy_quan/setting/get_item/many=1','choose_title'=>'选择帖子'),
				)
			),
			array(
				'title'=>'vip收费设置',
				'list'=>array(
					array('type'=>'switch','title'=>'关闭VIP?','name'=>'no_vip','help'=>'开启后，只有VIP才能发起接龙！'),
					array('type'=>'string','title'=>'月费','name'=>'mfee'),
					array('type'=>'string','title'=>'月费原价','name'=>'mfee0'),
					array('type'=>'string','title'=>'季费','name'=>'jfee'),
					array('type'=>'string','title'=>'季费原价','name'=>'jfee0'),
					array('type'=>'string','title'=>'年费','name'=>'yfee'),
					array('type'=>'string','title'=>'年费原价','name'=>'yfee0'),
					array('type'=>'switch','title'=>'关闭限制会员才能发红包贴','name'=>'isfee_hongbao','help'=>'开启后，免费会员才能发布的红包主题帖子！'),
					array('type'=>'image','title'=>'充值会员页面背景图','name'=>'vipbg','help'=>'建议尺寸：高360px*宽640px'),
				)
			),
			array(
				'title'=>'活动背景',
					'list'=>array(
						array(
							'type'=>'array',
							'name'=>'bgimgs',
							'add_tip'=>'添加一个活动背景',
								'list'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'背景图片'),
								),
								'details'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'背景图片','help'=>''),
								)
						)
					)
			),
			array(
				'title'=>'阅读模式',
					'list'=>array(
						array(
							'type'=>'array',
							'name'=>'readtpls',
							'add_tip'=>'添加一个阅读模式',
								'list'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'模式顶图'),
								),
								'details'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'模式顶图','help'=>''),
								)
						)
					)
			),
			array(
				'title'=>'幻灯片',
					'list'=>array(
						array(
							'type'=>'array',
							'name'=>'hdps',
							'add_tip'=>'添加一个幻灯片',
								'list'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'幻灯片图片'),
									array('type'=>'string','name'=>'url','title'=>'幻灯片链接'),
									
								),
								'details'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'幻灯片图片','help'=>''),
									array('type'=>'string','name'=>'url','title'=>'幻灯片链接'),
									
								)
						)
					)
			),
			array(
				'title'=>'页面UI',
				'list'=>array(
					//array('type'=>'colorpicker','title'=>'项目顶部颜色','name'=>'r_color','help'=>'自定义系统颜色系，默认： red'),
					array('type'=>'image','title'=>'会员顶部图片','name'=>'h_img','help'=>'建议尺寸：高360px*宽640px'),
					array('type'=>'colorpicker','title'=>'会员顶部颜色','name'=>'h_color','help'=>'自定义系统颜色系，默认： red'),
					array('type'=>'image','title'=>'帖子内容顶部图片','name'=>'o_img','help'=>'建议尺寸：高360px*宽640px'),
					//array('type'=>'colorpicker','title'=>'帖子列表顶部颜色','name'=>'o_color','help'=>'自定义系统颜色系，默认： red'),
					array('type'=>'image','title'=>'发红包弹窗背景图','name'=>'o_hongbao','help'=>'发红包弹窗背景图，建议尺寸：高520px*宽360px'),
				)
			),
			array(
				'title'=>'底部导航',
					'list'=>array(
									array('type'=>'array','name'=>'footernav','add_tip'=>'添加一个底部导航',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),
										array('type'=>'string','name'=>'action','title'=>'导航链接'),							
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),							
										array('type'=>'link','name'=>'action','from'=>'action','title'=>'导航链接'),
									)
								),
					)
			),
			array(
				'title'=>'会员中心DIY导航',
					'list'=>array(
									array('type'=>'array','name'=>'homenav','add_tip'=>'添加一个DIY导航',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),
										array('type'=>'string','name'=>'action','title'=>'导航链接'),							
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),							
										array('type'=>'link','name'=>'action','from'=>'action','title'=>'导航链接'),
									)
								),
					)
			),
			array(
				'title'=>'辅助应用',
					'list'=>array(
									array('type'=>'array','name'=>'plugins','add_tip'=>'添加一个辅助应用',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'应用名称'),
										array('type'=>'string','name'=>'desc','title'=>'应用描述'),
										array('type'=>'icon','name'=>'icon','title'=>'应用图标'),
										array('type'=>'string','name'=>'name','title'=>'应用标识'),							
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'应用名称'),
										array('type'=>'choose','action'=>'core/account.get_plugin/','name'=>'name','title'=>'应用标识','choose_title'=>'选择应用'),
										array('type'=>'icon','name'=>'icon','title'=>'应用图标'),							
										array('type'=>'string','name'=>'desc','title'=>'应用描述'),
									)
								),
					)
			),
			array(
				'title'=>'小程序广告设置',
				'list'=>array(
					array('type'=>'string','title'=>'微信小程序帖子间广告ID','name'=>'wxapp_ad01','help'=>'例如：adunit-513cf0c735a3d48a'),
					array('type'=>'string','title'=>'支付宝小程序帖子间广告ID','name'=>'aliapp_ad01'),
					array('type'=>'string','title'=>'百度小程序帖子间广告ID','name'=>'baiduapp_ad01'),
					array('type'=>'string','title'=>'头条小程序帖子间广告ID','name'=>'ttapp_ad01'),
					array('type'=>'image','title'=>'自定义广告图片','name'=>'diy_adimg','help'=>'建议尺寸：宽580px,高:200px'),
					array('type'=>'link','from'=>'action','title'=>'自定义广告链接','name'=>'diy_adlink'),
					array('type'=>'string','title'=>'自定义广告标题','name'=>'diy_adtitle'),
					array('type'=>'switch','title'=>'开启联盟广告?','name'=>'is_lianad'),
					array('type'=>'text','title'=>'联盟广告JScode','name'=>'lian_adcode'),
				)
			),
		),
	);
	$return['types']=get_form_types();
	$return['ismust']=array('0'=>'非必填','1'=>'必填');
	$return['pcd_types']=array('0'=>'区/县级圈','1'=>'市级圈','2'=>'省级圈');
    $return['withdraw']=$this->pay_types;
	$return['htmls']=$htmls;
	exi($return);
}

if($_RQ['op']=='get_item'){
	//会员列表
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$return['params']=$params=array();
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1,'noshow'=>0);
	$fields=array('title','id','status','type','createtime');
	if($_RQ['find']){
		$field=in_array($_RQ['field'],$fields)?$_RQ['field']:'title';
		$params[$field.' like']='%'.$_RQ['find'].'%';
		$return['params']['find']=$_RQ['find'];
		$return['params']['field']=$field;
	}
	$list=pdo_getslice('jy_quan_item',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			//整理返回数据
			if($_RQ['many']==1){
				$item['res']=array('id'=>$item['id'],'title'=>$item['title']);
			}else{
				$item['res']=$item['id'];
			}
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['htmls']=array(
		'type'=>'list',
		'list'=>array('data'=>'list','tip'=>'只显示审核通过的帖子！','del_one'=>false,'delall'=>false,'edit'=>false,'list'=>array(
		    array('name'=>'id','title'=>'id','type'=>'string'),
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'switch'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'res','title_field'=>'id','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'find','select_name'=>'field','select_title'=>'筛选','is_radio'=>true,'options'=>'fields'),
	);
	$return['fields']=array(
		'title'=>'标题',
	);
	exi($return);
}